/**
 * @author		Ben Layet
 * @version 	0.1
 * @date		5 Sep 2008
 * @copyright 	� Canon Europa N. V. 2004
 */
package org.learnaholic.application.test.ui;

import java.awt.Color;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;

import org.learnaholic.application.model.TestDialogElementDefinition;

/**
 * 
 */
public abstract class AbstractPanelTestComponent extends JPanel implements TestComponent
{
	private final JLabel label = new JLabel();
	private final TestDialogElementDefinition definition;

	/**
	 * @return the definition
	 */
	public TestDialogElementDefinition getDefinition()
	{
		return definition;
	}



	/**
	 * @param definition
	 */
	public AbstractPanelTestComponent(TestDialogElementDefinition definition)
	{
		this.definition = definition;
		setOpaque(false);
	}

	/**
	 * @param value
	 */
	public void setValue(String value)
	{
		label.setText(value);
	}

	/**
	 * @param answerMode
	 */
	public void setAnswerMode(boolean answerMode)
	{
		if(answerMode)
		{
			add(label);
		}
		else
		{
			remove(label);
		}
	}


	/**
	 * @return
	 */
	protected JLabel getLabel()
	{
		return label;
	}

	/**
	 * @param alignment
	 */
	public void setHorizontalAlignment(int alignment)
	{
		label.setHorizontalAlignment(alignment);
	}
	
	public void setFont(Font font)
	{
		if(null != label)
		{
			label.setFont(font);
		}
		super.setFont(font);
	}
	public void setForeground(Color color)
	{
		if(null != label)
		{
			label.setForeground(color);
		}
		super.setForeground(color);
	}
}
